 {
        
     cc.Class({
            extends: cc.Component,
            properties: {
                reconnectPre: {
                    default: null,
                    type: cc.Prefab
                }
            },
            onLoad: function () {
                this.reconnectTimes = 0, Global.persistNodeComps = this, Global.notificationCenter.on(Global.eventName.GAME_NETWORK_CONNECT_CLOSE, this.onNetWorkClose.bind(this), this),
                    Global.notificationCenter.on(Global.eventName.GAME_NETWORK_CONNECT_FAILED, this.onNetWorkClose.bind(this), this),
                    Global.notificationCenter.on(Global.eventName.GAME_NETWORK_CONNECT_SUCCESSED, this.reset.bind(this), this),
                    Global.notificationCenter.on(Global.eventName.GAME_SHOW_LOGOUT, this.showLogout.bind(this), this),
                    Global.notificationCenter.on(Global.eventName.GAME_SET_LOGOUT_CALLBACK, this.setLogoutCallback.bind(this), this),
                    Global.notificationCenter.on(Global.eventName.MSG_OPERATE_RECONNECT_MASK, this._operateReconnectMask.bind(this), this);
            },
            start: function () {
                this.node.width = cc.winSize.width, this.node.height = cc.winSize.height;
            },
            showLogout: function (e) {
                if (e) {
                    console.log("showLogout error:", e.code, e.info);
                    var t = e.info;
                    if (1 == e.code) console.log("重新连接: ", e.info), Global.netWork.closeAndReconnect(1); else if (4 == e.code) {
                        var n = Global.spriteAtlas.getReconnectSpf(), o = function () {
                            Global.netWork.closeAndReconnect(1), this._logoutCallback && (this._logoutCallbackData ? this._logoutCallback(this._logoutCallbackData) : this._logoutCallback(),
                                this._logoutCallback = null, this._logoutCallbackData = null);
                        }.bind(this);
                        Global.utils.showReconnectAlert(t, "重新连接", n, o), console.log("showLogout time:" + cc.sys.now());
                    } else console.log("error.code error!");
                }
            },
            setLogoutCallback: function (e) {
                if (e) {
                    var t = e.callback, n = e.data;
                    this._logoutCallback = t, this._logoutCallbackData = n;
                }
            },
            reset: function () {
                this._destroyReconnectShow(), this.unscheduleAllCallbacks(), cc.sys.platform == cc.sys.WECHAT_GAME && (this.reconnectTimes = 0),
                    this.isAllowCount = !0, this.setIsReconnecting(!1), Global.netWork.setIsLogout(!1),
                    Global.notificationCenter.emit(Global.eventName.GAME_RECONNECT), Global.utils.hideWaitting(),
                    console.log("persistNode reset this.isAllowCount:", this.isAllowCount), Global.UIPopupManager.RemoveAll(!0);
            },
            _operateReconnectMask: function (e) {
                console.log("_operateReconnectMask"), e && Global.TCP.connectStatus != Global.TCP.CONNECT_STATUS_OK && Global.TCP.connectStatus != Global.TCP.CONNECT_STATUS_OPENING ? this.createMask() : this._destroyReconnectShow();
            },
            _destroyReconnectShow: function () {
                this.reconnect && (this.reconnect.active = !1), this.isAllowCount = !1;
            },
            createMask: function () {
                this.reconnect ? this.reconnect.active = !0 : (this.reconnect = cc.instantiate(this.reconnectPre),
                    this.reconnect.setLocalZOrder(101), cc.game.addPersistRootNode(this.reconnect),
                    this.reconnect.setPosition(0, 0)), this.isAllowCount = !0;
            },
            onNetWorkClose: function () {
                if (!this.getIsReconnecting() && !Global._isInBackground) {
                    console.log("----------正在重连websocket--------- 第" + this.reconnectTimes + "次", Global.netWork.isLogout());
                    if (this.reconnectTimes < 3 && Global.netWork && !Global.netWork.isLogout()) this.reconnectTimes++,
                        this.createMask(), Global.netWork.closeAndReconnect(2), "1"; else if (Global.netWork && Global.netWork.isLogout()) console.log("正在重连中但是账号被挤掉了,,有重连弹框 2"),
                        "2"; else {
                        if (cc.sys.platform != cc.sys.WECHAT_GAME) return void console.log("只是连接后台服务器失败");
                        var e = Global.spriteAtlas.getRetrySpf();
                        Global.utils.showReconnectAlert("网络开小差了，跪求重连", "重试", e, function () {
                            console.log("----------重新连接websocket--------- "), Global.netWork.closeAndReconnect(3);
                        }), "3";
                    }
                }
            },
            setIsReconnecting: function (e) {
                this._isReconnecting = e;
            },
            getIsReconnecting: function () {
                return this._isReconnecting;
            }
        })
    }